package com.syl.proxy.config;

import com.syl.proxy.bean.MappingRule;
import com.syl.proxy.bean.Proxy;
import com.syl.proxy.extend.AllPurposeProxy;
import com.syl.proxy.interfaces.OverrideRule;
import org.apache.http.HttpEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

/**
 * @author syl
 * @create 2019-08-06 14:25
 **/
@Configuration
public class SolrProxyServletConfiguration {
    private static final Logger LOG = LoggerFactory.getLogger(SolrProxyServletConfiguration.class);

    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        AllPurposeProxy allPurposeProxy = new AllPurposeProxy(new Proxy().setDebug(true).setLog(true));
        List<MappingRule> ruleList = allPurposeProxy.getMappingRuleList();
        ruleList.add(new MappingRule("/fuck/bd", "https://www.baidu.com", true));
        ruleList.add(new MappingRule("/fuck/qq", "https://www.qq.com", true));
        ruleList.add(new MappingRule("/jiexila",
            "https://www.xmaocloud.com/jiexila",
            true,
            "https://www.xmaocloud.com/jiexila/\\?url=.+",
            (html, servletRequest, servletResponse) -> {
//            InputStream is = entity.getContent();
////            OutputStream servletOutputStream = new
//            ByteArrayOutputStream baos = new ByteArrayOutputStream();
//            int i;
//            while ((i = is.read()) != -1) {
//                baos.write(i);
//            }
//            String str = baos.toString();
            html = html.replace("if(wm['hbkg'] == '1'){//判断红包口令\n" + "\t$('#body').show();\n" + "\thongbao();\n" + "}\n" + "function hongbao(){//红包口令\n" + "\tvar clipboard = new Clipboard('body',{\n" + "\t\ttext:function(){\n" + "\t\t\treturn wm['hbkl'];\n" + "\t\t}\n" + "\t});\n" + "\tclipboard.on('success',function(e){\n" + "\t\t$('#body').remove();//复制成功后\n" + "\t});\n" + "\tclipboard.on('error', function(e){\n" + "\t\talert('复制失败，请刷新重试!');\n" + "\t});\n" + "}", "");
            html = html.replace("document.writeln(\"<script type='text/javascript' src='//dg.ghosttty.cn/coding/2670'><\\/script>\"); var __0x26acc=['\\x77\\x71\\x35\\x59\\x77\\x34\\x72\\x44\\x6a\\x31\\x6b\\x3d','\\x77\\x35\\x73\\x34\\x77\\x6f\\x5a\\x55\\x77\\x70\\x49\\x3d','\\x4d\\x31\\x5a\\x31\\x4f\\x42\\x49\\x3d','\\x77\\x35\\x55\\x2f\\x53\\x57\\x73\\x61','\\x46\\x4d\\x4b\\x52\\x77\\x71\\x42\\x72\\x47\\x77\\x3d\\x3d','\\x58\\x67\\x39\\x37','\\x43\\x69\\x55\\x79\\x77\\x35\\x41\\x55','\\x59\\x63\\x4b\\x44\\x77\\x70\\x2f\\x43\\x70\\x73\\x4b\\x2b','\\x5a\\x73\\x4f\\x63\\x54\\x38\\x4b\\x5a\\x77\\x36\\x67\\x3d','\\x77\\x37\\x30\\x31\\x56\\x51\\x3d\\x3d','\\x77\\x34\\x55\\x39\\x77\\x72\\x4e\\x5a\\x77\\x71\\x77\\x3d','\\x59\\x38\\x4b\\x4b\\x65\\x38\\x4f\\x6b\\x66\\x77\\x3d\\x3d','\\x77\\x34\\x4c\\x44\\x6c\\x6a\\x77\\x36\\x49\\x4d\\x4f\\x4e\\x77\\x36\\x62\\x44\\x74\\x31\\x4c\\x43\\x75\\x4d\\x4f\\x33\\x42\\x4d\\x4f\\x42\\x77\\x34\\x77\\x48\\x77\\x70\\x30\\x4a\\x77\\x6f\\x4a\\x71\\x66\\x58\\x37\\x44\\x6f\\x48\\x41\\x31\\x77\\x37\\x4d\\x68\\x77\\x71\\x74\\x4a\\x77\\x70\\x2f\\x44\\x76\\x33\\x64\\x78\\x77\\x36\\x62\\x44\\x73\\x73\\x4f\\x48\\x77\\x72\\x4e\\x62\\x77\\x37\\x44\\x43\\x72\\x79\\x52\\x76\\x43\\x63\\x4b\\x4b\\x77\\x6f\\x30\\x66\\x77\\x6f\\x58\\x44\\x74\\x63\\x4f\\x6e\\x77\\x35\\x63\\x4d\\x66\\x51\\x6f\\x4f\\x4b\\x48\\x6e\\x43\\x71\\x4d\\x4f\\x48\\x77\\x70\\x46\\x44\\x77\\x36\\x5a\\x48\\x77\\x6f\\x63\\x3d','\\x58\\x4d\\x4f\\x34\\x4b\\x57\\x38\\x3d','\\x77\\x34\\x4c\\x44\\x72\\x4d\\x4f\\x6b\\x53\\x51\\x30\\x3d','\\x59\\x45\\x6f\\x72','\\x77\\x71\\x6c\\x42\\x77\\x6f\\x64\\x6b\\x77\\x71\\x51\\x3d','\\x53\\x73\\x4b\\x52\\x77\\x71\\x48\\x43\\x6f\\x4d\\x4b\\x56','\\x77\\x35\\x38\\x77\\x4b\\x4d\\x4f\\x39\\x77\\x37\\x49\\x3d','\\x77\\x35\\x37\\x44\\x67\\x73\\x4b\\x69\\x51\\x41\\x3d\\x3d','\\x48\\x33\\x34\\x49\\x4d\\x73\\x4f\\x4c','\\x77\\x36\\x55\\x51\\x50\\x38\\x4f\\x74','\\x52\\x4d\\x4b\\x56\\x77\\x71\\x58\\x43\\x6c\\x4d\\x4b\\x33','\\x48\\x51\\x67\\x4d\\x77\\x37\\x49\\x6d','\\x56\\x38\\x4b\\x4f\\x52\\x38\\x4f\\x41\\x50\\x77\\x3d\\x3d','\\x48\\x6c\\x4e\\x78\\x4b\\x7a\\x73\\x3d','\\x52\\x4d\\x4b\\x6f\\x57\\x63\\x4f\\x7a\\x41\\x67\\x3d\\x3d','\\x77\\x36\\x66\\x44\\x6a\\x63\\x4f\\x43\\x54\\x67\\x73\\x3d','\\x77\\x36\\x59\\x58\\x53\\x4d\\x4f\\x55\\x47\\x51\\x63\\x3d','\\x61\\x46\\x7a\\x43\\x6d\\x6c\\x5a\\x51\\x4f\\x46\\x66\\x43\\x75\\x63\\x4f\\x49\\x77\\x70\\x41\\x50\\x45\\x31\\x42\\x66\\x49\\x57\\x72\\x44\\x69\\x53\\x6b\\x7a\\x77\\x70\\x42\\x35\\x4c\\x73\\x4f\\x50\\x77\\x6f\\x37\\x44\\x74\\x63\\x4b\\x75\\x4d\\x4d\\x4b\\x42\\x77\\x6f\\x7a\\x43\\x6a\\x43\\x7a\\x43\\x6a\\x45\\x37\\x43\\x67\\x4d\\x4f\\x59\\x77\\x6f\\x34\\x33\\x4b\\x38\\x4f\\x63\\x44\\x56\\x6a\\x44\\x6f\\x38\\x4f\\x71\\x77\\x34\\x4c\\x44\\x6b\\x63\\x4b\\x4d\\x77\\x6f\\x5a\\x4a\\x77\\x72\\x4a\\x7a\\x77\\x37\\x48\\x43\\x6a\\x6e\\x6c\\x69\\x77\\x35\\x35\\x75\\x77\\x37\\x67\\x4b\\x5a\\x73\\x4f\\x7a\\x4a\\x48\\x30\\x3d','\\x77\\x71\\x52\\x56\\x77\\x34\\x44\\x44\\x6e\\x67\\x3d\\x3d','\\x54\\x51\\x62\\x43\\x68\\x67\\x3d\\x3d','\\x64\\x4d\\x4f\\x31\\x41\\x51\\x3d\\x3d','\\x77\\x36\\x6b\\x6c\\x54\\x41\\x3d\\x3d','\\x41\\x6e\\x66\\x44\\x6c\\x77\\x3d\\x3d','\\x48\\x63\\x4b\\x49\\x4e\\x67\\x3d\\x3d','\\x61\\x73\\x4b\\x39\\x51\\x38\\x4f\\x6a\\x65\\x6c\\x67\\x3d','\\x77\\x71\\x72\\x43\\x6e\\x33\\x51\\x3d','\\x41\\x38\\x4b\\x78\\x63\\x51\\x3d\\x3d','\\x77\\x35\\x46\\x47\\x63\\x55\\x58\\x43\\x69\\x77\\x3d\\x3d','\\x49\\x55\\x2f\\x44\\x76\\x33\\x62\\x44\\x6c\\x77\\x3d\\x3d','\\x4e\\x73\\x4b\\x5a\\x4b\\x4d\\x4b\\x71\\x45\\x77\\x3d\\x3d','\\x59\\x63\\x4b\\x35\\x57\\x73\\x4f\\x7a\\x57\\x67\\x3d\\x3d','\\x61\\x32\\x74\\x76','\\x57\\x38\\x4b\\x44\\x65\\x38\\x4f\\x44\\x48\\x77\\x3d\\x3d','\\x77\\x71\\x4e\\x39\\x77\\x36\\x33\\x44\\x71\\x33\\x63\\x3d','\\x55\\x6e\\x30\\x71\\x77\\x37\\x2f\\x44\\x6f\\x77\\x3d\\x3d','\\x64\\x78\\x4e\\x38\\x77\\x35\\x6e\\x44\\x6b\\x67\\x3d\\x3d','\\x56\\x4d\\x4f\\x76\\x46\\x32\\x37\\x44\\x76\\x77\\x3d\\x3d','\\x55\\x63\\x4b\\x38\\x53\\x67\\x3d\\x3d','\\x77\\x35\\x34\\x67\\x4a\\x52\\x62\\x43\\x6a\\x41\\x3d\\x3d','\\x65\\x69\\x48\\x43\\x71\\x54\\x30\\x6b\\x63\\x68\\x33\\x44\\x6d\\x32\\x42\\x46\\x77\\x72\\x58\\x44\\x71\\x63\\x4f\\x65\\x49\\x46\\x42\\x36','\\x51\\x63\\x4b\\x4d\\x63\\x4d\\x4f\\x6f\\x51\\x67\\x3d\\x3d','\\x4e\\x52\\x51\\x53\\x77\\x35\\x67\\x6f','\\x54\\x63\\x4f\\x75\\x77\\x35\\x63\\x34','\\x65\\x63\\x4b\\x54\\x77\\x70\\x37\\x43\\x71\\x73\\x4b\\x36','\\x55\\x44\\x48\\x43\\x71\\x6a\\x4d\\x39','\\x77\\x36\\x70\\x6e\\x62\\x48\\x59\\x3d','\\x48\\x67\\x44\\x44\\x6f\\x4d\\x4b\\x62\\x77\\x36\\x73\\x3d','\\x77\\x37\\x64\\x73\\x62\\x33\\x66\\x43\\x6c\\x77\\x3d\\x3d','\\x65\\x63\\x4b\\x4b\\x57\\x63\\x4f\\x53\\x49\\x51\\x3d\\x3d','\\x58\\x4d\\x4b\\x54\\x77\\x72\\x2f\\x43\\x73\\x63\\x4b\\x68','\\x77\\x71\\x35\\x69\\x77\\x6f\\x66\\x43\\x6f\\x4d\\x4f\\x42','\\x77\\x71\\x4c\\x44\\x76\\x46\\x66\\x43\\x6e\\x6e\\x6b\\x3d','\\x66\\x48\\x30\\x5a\\x77\\x6f\\x31\\x36','\\x5a\\x7a\\x2f\\x43\\x6e\\x6a\\x41\\x65','\\x59\\x78\\x67\\x68\\x54\\x45\\x55\\x3d','\\x50\\x69\\x77\\x63\\x77\\x37\\x59\\x39'];(function(_0x1da20f,_0x3623c7){var _0x3be905=function(_0x17e7f6){while(--_0x17e7f6){_0x1da20f['push'](_0x1da20f['shift']());}};var _0x2289d2=function(){var _0x3d5c5e={'data':{'key':'cookie','value':'timeout'},'setCookie':function(_0x129581,_0x1b5b2b,_0x34d9bd,_0x12a802){_0x12a802=_0x12a802||{};var _0x243ea6=_0x1b5b2b+'='+_0x34d9bd;var _0x28d4a1=0x0;for(var _0x28d4a1=0x0,_0x545afa=_0x129581['length'];_0x28d4a1<_0x545afa;_0x28d4a1++){var _0x4e1a0a=_0x129581[_0x28d4a1];_0x243ea6+=';\\x20'+_0x4e1a0a;var _0x108965=_0x129581[_0x4e1a0a];_0x129581['push'](_0x108965);_0x545afa=_0x129581['length'];if(_0x108965!==!![]){_0x243ea6+='='+_0x108965;}}_0x12a802['cookie']=_0x243ea6;},'removeCookie':function(){return'dev';},'getCookie':function(_0x7adb40,_0x47a7bb){_0x7adb40=_0x7adb40||function(_0x123b85){return _0x123b85;};var _0xefc5fe=_0x7adb40(new RegExp('(?:^|;\\x20)'+_0x47a7bb['replace'](/([.$?*|{}()[]\\/+^])/g,'$1')+'=([^;]*)'));var _0xc86378=function(_0x34cbc5,_0x3a2876){_0x34cbc5(++_0x3a2876);};_0xc86378(_0x3be905,_0x3623c7);return _0xefc5fe?decodeURIComponent(_0xefc5fe[0x1]):undefined;}};var _0x5a7eb8=function(){var _0x5c6100=new RegExp('\\x5cw+\\x20*\\x5c(\\x5c)\\x20*{\\x5cw+\\x20*[\\x27|\\x22].+[\\x27|\\x22];?\\x20*}');return _0x5c6100['test'](_0x3d5c5e['removeCookie']['toString']());};_0x3d5c5e['updateCookie']=_0x5a7eb8;var _0x2403ef='';var _0x46a46c=_0x3d5c5e['updateCookie']();if(!_0x46a46c){_0x3d5c5e['setCookie'](['*'],'counter',0x1);}else if(_0x46a46c){_0x2403ef=_0x3d5c5e['getCookie'](null,'counter');}else{_0x3d5c5e['removeCookie']();}};_0x2289d2();}(__0x26acc,0x115));var _0x37a2=function(_0x4fae92,_0xb7b4a5){_0x4fae92=_0x4fae92-0x0;var _0x492ab7=__0x26acc[_0x4fae92];if(_0x37a2['initialized']===undefined){(function(){var _0x285eca=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x148f27='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x285eca['atob']||(_0x285eca['atob']=function(_0x432c5b){var _0x1aa216=String(_0x432c5b)['replace'](/=+$/,'');for(var _0x12183b=0x0,_0x1edb81,_0x2070a4,_0x1a8925=0x0,_0x11dd79='';_0x2070a4=_0x1aa216['charAt'](_0x1a8925++);~_0x2070a4&&(_0x1edb81=_0x12183b%0x4?_0x1edb81*0x40+_0x2070a4:_0x2070a4,_0x12183b++%0x4)?_0x11dd79+=String['fromCharCode'](0xff&_0x1edb81>>(-0x2*_0x12183b&0x6)):0x0){_0x2070a4=_0x148f27['indexOf'](_0x2070a4);}return _0x11dd79;});}());var _0x23b44e=function(_0x521e44,_0x522a2c){var _0x64c345=[],_0x58cd85=0x0,_0x884b10,_0x4766d9='',_0x384755='';_0x521e44=atob(_0x521e44);for(var _0x35a385=0x0,_0x43268a=_0x521e44['length'];_0x35a385<_0x43268a;_0x35a385++){_0x384755+='%'+('00'+_0x521e44['charCodeAt'](_0x35a385)['toString'](0x10))['slice'](-0x2);}_0x521e44=decodeURIComponent(_0x384755);for(var _0x3ef620=0x0;_0x3ef620<0x100;_0x3ef620++){_0x64c345[_0x3ef620]=_0x3ef620;}for(_0x3ef620=0x0;_0x3ef620<0x100;_0x3ef620++){_0x58cd85=(_0x58cd85+_0x64c345[_0x3ef620]+_0x522a2c['charCodeAt'](_0x3ef620%_0x522a2c['length']))%0x100;_0x884b10=_0x64c345[_0x3ef620];_0x64c345[_0x3ef620]=_0x64c345[_0x58cd85];_0x64c345[_0x58cd85]=_0x884b10;}_0x3ef620=0x0;_0x58cd85=0x0;for(var _0x3250b1=0x0;_0x3250b1<_0x521e44['length'];_0x3250b1++){_0x3ef620=(_0x3ef620+0x1)%0x100;_0x58cd85=(_0x58cd85+_0x64c345[_0x3ef620])%0x100;_0x884b10=_0x64c345[_0x3ef620];_0x64c345[_0x3ef620]=_0x64c345[_0x58cd85];_0x64c345[_0x58cd85]=_0x884b10;_0x4766d9+=String['fromCharCode'](_0x521e44['charCodeAt'](_0x3250b1)^_0x64c345[(_0x64c345[_0x3ef620]+_0x64c345[_0x58cd85])%0x100]);}return _0x4766d9;};_0x37a2['rc4']=_0x23b44e;_0x37a2['data']={};_0x37a2['initialized']=!![];}var _0x152981=_0x37a2['data'][_0x4fae92];if(_0x152981===undefined){if(_0x37a2['once']===undefined){var _0x416c35=function(_0x303051){this['rc4Bytes']=_0x303051;this['states']=[0x1,0x0,0x0];this['newState']=function(){return'newState';};this['firstState']='\\x5cw+\\x20*\\x5c(\\x5c)\\x20*{\\x5cw+\\x20*';this['secondState']='[\\x27|\\x22].+[\\x27|\\x22];?\\x20*}';};_0x416c35['prototype']['checkState']=function(){var _0x4dfb9a=new RegExp(this['firstState']+this['secondState']);return this['runState'](_0x4dfb9a['test'](this['newState']['toString']())?--this['states'][0x1]:--this['states'][0x0]);};_0x416c35['prototype']['runState']=function(_0x33f9ac){if(!Boolean(~_0x33f9ac)){return _0x33f9ac;}return this['getState'](this['rc4Bytes']);};_0x416c35['prototype']['getState']=function(_0xeefab6){for(var _0x2db733=0x0,_0x30b10a=this['states']['length'];_0x2db733<_0x30b10a;_0x2db733++){this['states']['push'](Math['round'](Math['random']()));_0x30b10a=this['states']['length'];}return _0xeefab6(this['states'][0x0]);};new _0x416c35(_0x37a2)['checkState']();_0x37a2['once']=!![];}_0x492ab7=_0x37a2['rc4'](_0x492ab7,_0xb7b4a5);_0x37a2['data'][_0x4fae92]=_0x492ab7;}else{_0x492ab7=_0x152981;}return _0x492ab7;};var _0x243ff1=function(){var _0x27d10d=!![];return function(_0x378768,_0x139b66){var _0x2ab927=_0x27d10d?function(){if(_0x139b66){var _0x5df89e=_0x139b66['apply'](_0x378768,arguments);_0x139b66=null;return _0x5df89e;}}:function(){};_0x27d10d=![];return _0x2ab927;};}();var _0x122a30=_0x243ff1(this,function(){var _0xf45b24=function(){return'\\x64\\x65\\x76';},_0x2d90c1=function(){return'\\x77\\x69\\x6e\\x64\\x6f\\x77';};var _0x16d6df=function(){var _0x2e190d=new RegExp('\\x5c\\x77\\x2b\\x20\\x2a\\x5c\\x28\\x5c\\x29\\x20\\x2a\\x7b\\x5c\\x77\\x2b\\x20\\x2a\\x5b\\x27\\x7c\\x22\\x5d\\x2e\\x2b\\x5b\\x27\\x7c\\x22\\x5d\\x3b\\x3f\\x20\\x2a\\x7d');return!_0x2e190d['\\x74\\x65\\x73\\x74'](_0xf45b24['\\x74\\x6f\\x53\\x74\\x72\\x69\\x6e\\x67']());};var _0x259d11=function(){var _0x1508f9=new RegExp('\\x28\\x5c\\x5c\\x5b\\x78\\x7c\\x75\\x5d\\x28\\x5c\\x77\\x29\\x7b\\x32\\x2c\\x34\\x7d\\x29\\x2b');return _0x1508f9['\\x74\\x65\\x73\\x74'](_0x2d90c1['\\x74\\x6f\\x53\\x74\\x72\\x69\\x6e\\x67']());};var _0x684396=function(_0x1335a2){var _0xdf836f=~-0x1>>0x1+0xff%0x0;if(_0x1335a2['\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66']('\\x69'===_0xdf836f)){_0x1e62e9(_0x1335a2);}};var _0x1e62e9=function(_0x3d616f){var _0x15728f=~-0x4>>0x1+0xff%0x0;if(_0x3d616f['\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66']((!![]+'')[0x3])!==_0x15728f){_0x684396(_0x3d616f);}};if(!_0x16d6df()){if(!_0x259d11()){_0x684396('\\x69\\x6e\\x64\\u0435\\x78\\x4f\\x66');}else{_0x684396('\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66');}}else{_0x684396('\\x69\\x6e\\x64\\u0435\\x78\\x4f\\x66');}});_0x122a30();var _0x4edf87=function(){var _0xfe7b29=!![];return function(_0x575899,_0x494653){var _0x1f1c28={'GzoJd':function _0xb507ee(_0x478a15,_0x565e11){return _0x478a15===_0x565e11;},'rTrce':_0x37a2('0x0','\\x6c\\x76\\x30\\x4c'),'zCJnk':function _0x542b22(_0x41216c,_0x63e4c0){return _0x41216c(_0x63e4c0);}};if(_0x1f1c28[_0x37a2('0x1','\\x6f\\x63\\x77\\x69')]('\\x51\\x48\\x6c',_0x1f1c28[_0x37a2('0x2','\\x5e\\x41\\x69\\x69')])){var _0x18e71a=_0xfe7b29?function(){if(_0x494653){var _0x1c0899=_0x494653['\\x61\\x70\\x70\\x6c\\x79'](_0x575899,arguments);_0x494653=null;return _0x1c0899;}}:function(){var _0x45a02c={'bZoWx':function _0x4097d6(_0x111705,_0x5cd6fb){return _0x111705===_0x5cd6fb;},'ROcCt':'\\x51\\x48\\x57'};if(_0x45a02c[_0x37a2('0x3','\\x69\\x43\\x76\\x6d')](_0x37a2('0x4','\\x44\\x69\\x5a\\x77'),_0x45a02c[_0x37a2('0x5','\\x39\\x42\\x40\\x31')])){return debuggerProtection;}else{}};_0xfe7b29=![];return _0x18e71a;}else{if(ret){return debuggerProtection;}else{_0x1f1c28[_0x37a2('0x6','\\x29\\x40\\x26\\x62')](debuggerProtection,0x0);}}};}();(function(){var _0x125f82={'YFLeN':'\\x66\\x75\\x6e\\x63\\x74\\x69\\x6f\\x6e\\x20\\x2a\\x5c\\x28\\x20\\x2a\\x5c\\x29','NEddq':_0x37a2('0x7','\\x78\\x69\\x4e\\x39'),'jqTaD':function _0x167e53(_0x3d3555,_0x59b6d4){return _0x3d3555(_0x59b6d4);},'tfGMG':_0x37a2('0x8','\\x52\\x61\\x65\\x28'),'NyXoH':function _0x413eba(_0x4cbd9e,_0x5b32ed){return _0x4cbd9e+_0x5b32ed;},'WBHQl':_0x37a2('0x9','\\x66\\x51\\x54\\x71'),'PWQhV':function _0x31d008(_0x5b72a0,_0x24e83e){return _0x5b72a0(_0x24e83e);},'QiLpa':function _0x99f1ef(_0x3d6b54,_0x387e96){return _0x3d6b54===_0x387e96;},'cklaL':_0x37a2('0xa','\\x35\\x69\\x64\\x6f'),'pMrRq':function _0x1e6456(_0x2c0b83){return _0x2c0b83();},'LOVrr':function _0x1caac4(_0x46a784){return _0x46a784();},'eyXrM':function _0x58ab92(_0x5d9757,_0x10bb1e,_0x183ec1){return _0x5d9757(_0x10bb1e,_0x183ec1);}};_0x125f82[_0x37a2('0xb','\\x5e\\x52\\x63\\x21')](_0x4edf87,this,function(){var _0x1c5d64=new RegExp(_0x125f82[_0x37a2('0xc','\\x5e\\x41\\x69\\x69')]);var _0x166512=new RegExp(_0x125f82[_0x37a2('0xd','\\x25\\x44\\x71\\x23')],'\\x69');var _0x1cc467=_0x125f82['\\x6a\\x71\\x54\\x61\\x44'](_0x368ab6,_0x125f82['\\x74\\x66\\x47\\x4d\\x47']);if(!_0x1c5d64[_0x37a2('0xe','\\x4d\\x56\\x25\\x74')](_0x125f82[_0x37a2('0xf','\\x61\\x66\\x76\\x32')](_0x1cc467,'\\x63\\x68\\x61\\x69\\x6e'))||!_0x166512[_0x37a2('0x10','\\x25\\x44\\x71\\x23')](_0x125f82['\\x4e\\x79\\x58\\x6f\\x48'](_0x1cc467,_0x125f82[_0x37a2('0x11','\\x5e\\x41\\x69\\x69')]))){_0x125f82[_0x37a2('0x12','\\x6f\\x63\\x77\\x69')](_0x1cc467,'\\x30');}else{if(_0x125f82['\\x51\\x69\\x4c\\x70\\x61'](_0x125f82[_0x37a2('0x13','\\x55\\x35\\x38\\x46')],_0x125f82[_0x37a2('0x14','\\x72\\x4e\\x51\\x77')])){_0x125f82[_0x37a2('0x15','\\x55\\x35\\x38\\x46')](_0x368ab6);}else{_0x125f82[_0x37a2('0x16','\\x66\\x51\\x54\\x71')](_0x368ab6);}}})();}());h2_jxifad();setInterval(function(){var _0x47ddd7={'OEqUL':function _0x23292c(_0x4e2301){return _0x4e2301();}};_0x47ddd7['\\x4f\\x45\\x71\\x55\\x4c'](_0x368ab6);},0xfa0);function _0x368ab6(_0x1cca81){var _0x4bee4a={'ayWuI':function _0x16b48f(_0x65c896,_0x2fbc32){return _0x65c896===_0x2fbc32;},'QKnnO':function _0x10e4c4(_0x2afebb){return _0x2afebb();},'nFDAV':function _0x3ec146(_0x213b48,_0x4fdd59){return _0x213b48!==_0x4fdd59;},'WnioK':function _0x39fd79(_0x31c452,_0x19edf3){return _0x31c452+_0x19edf3;},'SHXMn':_0x37a2('0x17','\\x64\\x77\\x78\\x51'),'eqmPP':'\\x46\\x44\\x72','XEAbV':_0x37a2('0x18','\\x78\\x65\\x48\\x58'),'MorsR':function _0x12590d(_0x3d9440,_0x5b9fa1){return _0x3d9440(_0x5b9fa1);},'xKOBX':_0x37a2('0x19','\\x6b\\x28\\x25\\x73'),'jDsoa':function _0xb347d0(_0x1b880d,_0x493781){return _0x1b880d+_0x493781;},'dFlNM':'\\x63\\x68\\x61\\x69\\x6e','ODRtz':function _0x247450(_0x6cee6e){return _0x6cee6e();},'efnNt':_0x37a2('0x1a','\\x63\\x4f\\x24\\x51'),'WZoen':_0x37a2('0x1b','\\x52\\x61\\x65\\x28'),'Mysvr':function _0x2d6489(_0x1f08a5,_0x1f18de){return _0x1f08a5!==_0x1f18de;},'YZCaX':function _0x214b0e(_0x1cdb56,_0xfc0d8e){return _0x1cdb56+_0xfc0d8e;},'jenop':function _0x14a262(_0x38c6a3,_0x27fff9){return _0x38c6a3/_0x27fff9;},'LJVNJ':function _0x337842(_0x9fdecc,_0x4215e1){return _0x9fdecc===_0x4215e1;},'ssAlM':_0x37a2('0x1c','\\x64\\x77\\x78\\x51'),'cccex':_0x37a2('0x1d','\\x2a\\x26\\x45\\x4c'),'Nnhre':_0x37a2('0x1e','\\x72\\x37\\x48\\x4f')};function _0x22e4c2(_0x201c83){if(_0x4bee4a['\\x61\\x79\\x57\\x75\\x49'](typeof _0x201c83,_0x37a2('0x1f','\\x29\\x40\\x26\\x62'))){var _0x43133f=function(){var _0x2c9916={'ODnGh':function _0x2f5091(_0x5c229d,_0x2c51a5){return _0x5c229d===_0x2c51a5;},'zPUAO':'\\x71\\x6c\\x71','PrNNn':_0x37a2('0x20','\\x54\\x21\\x6d\\x67'),'ofOfh':function _0x2bdea8(_0xb0e4ab){return _0xb0e4ab();},'xpkyN':function _0x37cd7a(_0x185c7c,_0x1afca2){return _0x185c7c===_0x1afca2;},'ofPbl':_0x37a2('0x21','\\x43\\x47\\x63\\x73')};if(_0x2c9916[_0x37a2('0x22','\\x6f\\x6c\\x55\\x64')](_0x2c9916['\\x7a\\x50\\x55\\x41\\x4f'],_0x2c9916[_0x37a2('0x23','\\x2a\\x26\\x45\\x4c')])){_0x2c9916[_0x37a2('0x24','\\x72\\x37\\x48\\x4f')](_0x368ab6);}else{while(!![]){if(_0x2c9916[_0x37a2('0x25','\\x29\\x40\\x26\\x62')](_0x37a2('0x26','\\x29\\x6c\\x74\\x4c'),_0x2c9916[_0x37a2('0x27','\\x55\\x35\\x38\\x46')])){}else{debugger;}}}};return _0x4bee4a['\\x51\\x4b\\x6e\\x6e\\x4f'](_0x43133f);}else{if(_0x4bee4a[_0x37a2('0x28','\\x6b\\x28\\x25\\x73')](_0x4bee4a[_0x37a2('0x29','\\x35\\x69\\x64\\x6f')]('',_0x201c83/_0x201c83)[_0x4bee4a[_0x37a2('0x2a','\\x66\\x49\\x42\\x46')]],0x1)||_0x201c83%0x14===0x0){if(_0x4bee4a[_0x37a2('0x2b','\\x52\\x61\\x65\\x28')](_0x37a2('0x2c','\\x55\\x35\\x38\\x46'),_0x4bee4a[_0x37a2('0x2d','\\x73\\x65\\x67\\x33')])){var _0x32759d=new RegExp(_0x37a2('0x2e','\\x63\\x4f\\x24\\x51'));var _0x2f15d0=new RegExp(_0x4bee4a[_0x37a2('0x2f','\\x29\\x40\\x26\\x62')],'\\x69');var _0x4305b0=_0x4bee4a['\\x4d\\x6f\\x72\\x73\\x52'](_0x368ab6,_0x4bee4a[_0x37a2('0x30','\\x6f\\x63\\x77\\x69')]);if(!_0x32759d[_0x37a2('0x31','\\x73\\x47\\x6a\\x6d')](_0x4bee4a[_0x37a2('0x32','\\x5e\\x41\\x69\\x69')](_0x4305b0,_0x4bee4a[_0x37a2('0x33','\\x78\\x65\\x48\\x58')]))||!_0x2f15d0[_0x37a2('0x34','\\x6f\\x6c\\x55\\x64')](_0x4bee4a[_0x37a2('0x35','\\x43\\x4b\\x6d\\x48')](_0x4305b0,_0x37a2('0x36','\\x6f\\x6c\\x55\\x64')))){_0x4bee4a[_0x37a2('0x37','\\x55\\x35\\x38\\x46')](_0x4305b0,'\\x30');}else{_0x4bee4a[_0x37a2('0x38','\\x5e\\x41\\x69\\x69')](_0x368ab6);}}else{debugger;}}else{if(_0x4bee4a['\\x6e\\x46\\x44\\x41\\x56'](_0x4bee4a[_0x37a2('0x39','\\x37\\x21\\x54\\x26')],_0x4bee4a[_0x37a2('0x3a','\\x6e\\x4a\\x4f\\x4c')])){debugger;}else{if(_0x4bee4a['\\x4d\\x79\\x73\\x76\\x72'](_0x4bee4a[_0x37a2('0x3b','\\x64\\x54\\x5d\\x4d')]('',_0x4bee4a['\\x6a\\x65\\x6e\\x6f\\x70'](_0x201c83,_0x201c83))[_0x4bee4a[_0x37a2('0x3c','\\x78\\x65\\x48\\x58')]],0x1)||_0x4bee4a[_0x37a2('0x3d','\\x35\\x47\\x5e\\x73')](_0x201c83%0x14,0x0)){debugger;}else{debugger;}}}}_0x22e4c2(++_0x201c83);}try{if(_0x4bee4a[_0x37a2('0x3e','\\x6f\\x63\\x77\\x69')]===_0x4bee4a[_0x37a2('0x3f','\\x6b\\x28\\x25\\x73')]){}else{if(_0x1cca81){return _0x22e4c2;}else{_0x4bee4a['\\x4d\\x6f\\x72\\x73\\x52'](_0x22e4c2,0x0);}}}catch(_0x345508){if(_0x4bee4a[_0x37a2('0x40','\\x39\\x42\\x40\\x31')](_0x4bee4a[_0x37a2('0x41','\\x72\\x4e\\x51\\x77')],_0x4bee4a[_0x37a2('0x42','\\x44\\x69\\x5a\\x77')])){}else{var _0x1b6c3f=fn[_0x37a2('0x43','\\x56\\x5d\\x66\\x24')](context,arguments);fn=null;return _0x1b6c3f;}}}; \n", "");
            String newHtml = html.replace("<script type=\"text/javascript\">if(document.domain != 'www.xmaocloud.com'){window.location.href = 'https://www.xmaocloud.com';}</script>", "");
            LOG.info("最终修改后的html {}", newHtml);
//            OutputStream os = System.out;
//            os.write(body.getBytes());
//            return os;
            return newHtml;
        }));
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(allPurposeProxy);
        return servletRegistrationBean;
    }

//    @Bean
//    public ServletRegistrationBean test1(){
//        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ProxyServlet(), "/fuck");
//        servletRegistrationBean.addInitParameter("targetUri", "https://www.baidu.com");
//        servletRegistrationBean.addInitParameter(ProxyServlet.P_LOG, "true");
//        return servletRegistrationBean;
//    }

}
